package cn.gengar.domain.trade.service.lock.factory;

import cn.gengar.domain.trade.model.entity.GroupBuyActivityEntity;
import cn.gengar.domain.trade.model.entity.TradeRuleCommandEntity;
import cn.gengar.domain.trade.model.entity.TradeRuleFilterBackEntity;
import cn.gengar.domain.trade.service.lock.filter.ActivityUsabilityRuleFilter;
import cn.gengar.domain.trade.service.lock.filter.UserTaskLimitRuleFilter;
import cn.gengar.types.design.framework.link.model2.LinkArmory;
import cn.gengar.types.design.framework.link.model2.chain.BusinessLinkedList;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;

/**
 * @author Fuzhengwei bugstack.cn @小傅哥
 * @description 交易结算规则过滤工厂
 * @create 2025-01-29 09:17
 */
@Slf4j
@Service
public class TradeSettlementRuleFilterFactory {

    @Bean("tradeRuleFilter")
    public BusinessLinkedList<TradeRuleCommandEntity, TradeSettlementRuleFilterFactory.DynamicContext, TradeRuleFilterBackEntity> tradeRuleFilter(
            ActivityUsabilityRuleFilter activityUsabilityRuleFilter, UserTaskLimitRuleFilter userTaskLimitRuleFilter) {

        LinkArmory<TradeRuleCommandEntity, TradeSettlementRuleFilterFactory.DynamicContext, TradeRuleFilterBackEntity> businessLinkedList =
                new LinkArmory<>("交易结算规则过滤链", activityUsabilityRuleFilter, userTaskLimitRuleFilter);

        return businessLinkedList.getLogicLink();
    }


    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    public static class DynamicContext {

        private GroupBuyActivityEntity groupBuyActivityEntity;

    }

}
